<template>
	<view>
		<view class="u-page">
			<!-- 所有内容的容器 -->
			<Home v-if='showPage==="home"' />
			<Campus v-if='showPage==="campus"' />
			<AiGuidanceVue v-if="showPage=='ai'"></AiGuidanceVue>
			<UserIndex v-if="showPage=='mine'"></UserIndex>
			<Message v-if="showPage=='message'"></Message>
		</view>
		<u-tabbar v-model="current" bg-color="#FFFFFF" :icon-size='80' height="70px" :border-top="false"
			:mid-button="true" :list="list">
		</u-tabbar>
		<Ai></Ai>
	</view>
</template>

<script>
	import Home from './tabBar/Home/Index.vue'
	import Notice from './tabBar/Notice/Index.vue'
	import Personal from './tabBar/Personal/Index.vue'
	import Campus from './Introduce/campus.vue'

	import Questionnaire from './tabBar/Questionnaire/Index.vue'
	import MedicalAssistant from './MedicalAssistant/MedicalAssistant.vue'
	import UserIndex from "./User/index.vue"
	import Message from "./Messages/index.vue"
	import Ai from "@/pages/ai/TransitionButton.vue"
	import AiViewVue from './ai/AiView.vue'
	import AiGuidanceVue from './Home/ServePatient/AiGuidance.vue'
	import {
		getMenu
	} from '@/api/home.js'
	import {
		weixinCode
	} from '@/api/login.js'
	import {
		themeColor
	} from '@/static/js/theme.js'
	import {
		mapGetters
	} from 'vuex'
	const listItem = [{
		active: false,
		name: "排班",
		describe: '#afddff'
	}, {
		active: false,
		name: "查询身份证号为510124198110251429的患者信息",
		describe: '#e4ffd5'
	}, {
		active: false,
		name: "智能问诊",
		describe: '#ffe9ff'
	}, {
		active: false,
		name: "智能问诊",
		describe: '#fff9f3'
	}, {
		active: false,
		name: "智能问诊",
		describe: '#efffe1'
	}]
	export default {
		components: {
			Notice,
			Home,
			Questionnaire,
			Personal,
			Campus,
			MedicalAssistant,
			Ai,
			UserIndex,
			Message,
			AiViewVue,
			AiGuidanceVue
		},
		data() {
			return {
				show: false,
				value: 1,
				window,
				themeColor,
				list: [{
						iconPath: "/static/images/icon/home-no.png",
						selectedIconPath: "/static/images/icon/home-active.png",
						text: '首页',
						customIcon: false,
						pathName: 'home',
					},
					{
						iconPath: "/static/images/icon/hospital-no.png",
						selectedIconPath: "/static/images/icon/hospital-active.png",
						text: '医院信息',
						customIcon: false,
						pathName: 'campus'
					},
					{
						iconPath: "/static/images/icon/tabbar-ai.png",
						selectedIconPath: "/static/images/icon/tabbar-ai.png",
						text: '',
						customIcon: false,
						midButton: true,
						pathName: 'ai'
					},
					{
						iconPath: "/static/images/icon/message-no.png",
						selectedIconPath: "/static/images/icon/message-active.png",
						text: '消息',
						customIcon: false,
						pathName: 'message'
					},
					// {
					// 	iconPath: "file-text",
					// 	selectedIconPath: "file-text-fill",
					// 	text: '问卷',
					// 	customIcon: false,
					// 	pathName:'questionnaire'
					// },


					{
						iconPath: "/static/images/icon/mine-no.png",
						selectedIconPath: "/static/images/icon/mine-active.png",
						text: '我的',
						customIcon: false,
						pathName: 'mine'
					}
				],
				current: 0, //当前激活索引
				load: true,
				dialogVisible: false,
				listItem: listItem,
				// percentNow:10,
				// timerId: null
			}
		},
		async onLoad(option) {
			// this.getOpenId(option.code)
			//等待登录成功
			// this.initTimer()
			// await this.$onLaunched
			// this.percentNow = 100
			// this.getTabBar();
		},
		computed: {
			...mapGetters(['userInfo']),
			showPage() {
				if (this.list.length) {
					uni.setNavigationBarTitle({
						title: this.list[this.current].text
					})
					return this.list[this.current].pathName
				} else {
					return ''
				}
			},
		},
		methods: {
			centerButtonClick() {
				this.current = 2
			}
			// getOpenId(code = 1) {
			// 	// let url = `https://api.weixin.qq.com/sns/oauth2/access_token?appid=wx8949357af2931694&secret=273476fe3ce6324adb3e9ee7c3c9f4cd&code=${code}&grant_type=authorization_code`
			// 	// uni.request({
			// 	//   url,
			// 	//   success(res) {
			// 	//     alert(res)
			// 	//   }
			// 	// })
			// 	weixinCode({
			// 		code
			// 	}).then(res => {
			// 		console.log(res)
			// 	})
			// },
			// initTimer() {
			// 	this.timerId = setInterval(() => {
			// 		this.percentNow = this.percentNow + 10
			// 		if (this.percentNow > 80) {
			// 			clearInterval(this.timerId)
			// 			this.timerId = null
			// 		}
			// 	}, 500)
			// },
			// getTabBar() {
			// 	const type = 1;
			// 	getMenu({
			// 		type
			// 	}).then(data => {
			// 		this.load = false
			// 		let list = [],
			// 			res = data[type];
			// 		res.forEach(item => {
			// 			list.push({
			// 				iconPath: item.iconPath,
			// 				selectedIconPath: `${item.iconPath}-fill`,
			// 				text: item.name,
			// 				customIcon: false,
			// 				pathName: item.route
			// 			})
			// 		})
			// 		this.list = list;
			// 	}).catch(e => {
			// 		this.load = false
			// 	})
			// },
		}
	}
</script>

<style lang="scss">
	.u-page {
		height: calc(100vh - 70px);
		overflow: auto;
		position: relative;
	}
</style>